#ifndef SOEM_MASTER_H
#define SOEM_MASTER_H

#include "EtherCATMaster.h"
#include <string>

// 前向声明，避免包含完整的SOEM头文件
struct ec_slavet;
struct ec_groupt;

// SOEM EtherCAT主站实现类
class SOEMMaster : public EtherCATMaster {
private:
    // SOEM相关成员变量
    char* ifname;
    bool inOP;
    bool needlf;
    int expectedWKC;
    int wkc;
    int currentgroup;
    uint8_t* IOmap;
    bool forceByteAlignment;
    
    // 周期时间（微秒）
    static const uint32_t CYCLE_TIME_US = 5000; // 5ms
    
public:
    SOEMMaster();
    ~SOEMMaster() override;
    
    // 实现抽象接口
    bool init(const std::string& ifname) override;
    bool configureSlaves() override;
    bool activate() override;
    bool receiveProcessData() override;
    bool sendProcessData() override;
    bool checkMasterState() override;
    bool checkDomainState() override;
    bool checkSlaveConfigState() override;
    void shutdown() override;
    void cyclicTask() override;
    
    // SOEM特有方法
    void checkSlaveStatus();
};

#endif // SOEM_MASTER_H